package github.sf.fw.tools.db.impl.mysql;


import github.sf.fw.tools.db.QueryFilter;

public interface MysqlConstants {
    String DEFAULT_DRIVER = "com.mysql.cj.jdbc.Driver";
    String SHOW_ALL_DATABASE_CMD = "SHOW DATABASES";
    String QUERY_TABLE_INFO = "select a.* from information_schema.`TABLES` a where a.TABLE_SCHEMA=?";
    String QUERY_TABLE_COUNT_OF_SCHEMA = "select count(*) from information_schema.`TABLES` a where a.TABLE_SCHEMA=?";
    String QUERY_COLUMN_INFO = "select a.* from information_schema.`COLUMNS` a where a.TABLE_SCHEMA=? and a.TABLE_NAME=?";
    String COL_DATABASE = "SCHEMA_NAME";

    String COL_TABLE_NAME = "TABLE_NAME";
    String COL_TABLE_COMMENT = "TABLE_COMMENT";

    String COL_COLUMN_NAME = "COLUMN_NAME";
    String COL_COLUMN_TYPE = "COLUMN_TYPE";
    String COL_COLUMN_CHARSET = "CHARACTER_SET_NAME";
    String COL_COLUMN_COLUMN_KEY = "COLUMN_KEY";
    String COL_COLUMN_COMMENT = "COLUMN_COMMENT";

    String COL_COUNT = "tableCount";
    String QUERY_TABLE_COUNT = "select count(*) as tableCount from {Table}";
    String QUERY_SQL_COUNT = "select count(*) as tableCount from ({Sql}) a_1";

    String QUERY_TABLE_LIMIT = "select a_.* from ( {sql} ) a_ limit {start},{end}";

    String PRIMARY_KEY="primary key";

    String[] FILTER_TABLES = new String[]{
            "information_schema",
            "mysql",
            "performance_schema",
            "sys"
    };
    QueryFilter<String> MYSQL_TABLE_FILTER = new QueryFilter<String>() {
        @Override
        public boolean isSkip(String param) {
            for (String filterTable : FILTER_TABLES) {
                if (filterTable.equals(param)) {
                    return true;
                }
            }
            return false;
        }
    };
}
